#ifndef CNATIVEHANDLER_H
#define CNATIVEHANDLER_H

#include <QDebug>
#include <QWidget>
#include <QWindowStateChangeEvent>

#include "ModelHandler.h"

#define Q_OS_DUMMY

class CNativeHandler : public ModelHandler {
    Q_OBJECT
public:
    explicit CNativeHandler(QWidget *parent = nullptr);
    ~CNativeHandler();

    friend class CNativeWidget;

public:
    QWidget *widget() const;
    bool resizable() const;
    void setResizable(bool resizable);

    QMargins resizeMargins() const;
    void setResizeMargins(const QMargins &margins);

    QColor borderColor() const;
    void setBorderColor(const QColor &borderColor);

public:
    void centralize(double r = 0);
    void maximize();
    void minimize();
    void normalize();
    void fullScreen();
    virtual void showForward();

protected:
    void hideWindowFrame();

    virtual void updateResizable();

    virtual void showEventEx(QShowEvent *event);
    virtual void paintEventEx(QPaintEvent *event);

    // Avoid calling QWidget::winId() in constructor
    virtual void winIdChangeEventEx(QEvent *event);
    virtual void windowTitleChangeEventEx(QEvent *event);
    virtual void windowStateChangeEventEx(QWindowStateChangeEvent *event);

protected:
    QWidget *w;

    bool m_resizable;
    QMargins m_resizeMargins;
    QColor m_borderColor;

    virtual bool commonEventFilter(QEvent *event);
    virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result);

signals:
    void testMouseOnCaption(bool *result, bool set = false);
    void testNative(bool *result, bool set = false);
};

#endif // CNATIVEHANDLER_H
